﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace FPC.Offer.UI.GeneralProcessor.SkyDriveHand
{
    /// <summary>
    /// shareHandler 的摘要说明
    /// </summary>
    public class shareHandler : IHttpHandler
    {
        FPC.Offer.Service.System_ShareTableSerevice Sky = new Service.System_ShareTableSerevice();
        FPC.Offer.Service.System_SubfolderTableService Sk = new Service.System_SubfolderTableService();
        public void ProcessRequest(HttpContext context)
        {

            context.Response.ContentType = "text/plain";
            int id = Convert.ToInt32(context.Request["id"]);
            var name = context.Request["name"];
            Model.Subfolder c = Sk.Find(w => w.SId == id).FirstOrDefault();
            Model.Dropbox_ShareFileTable s = new Model.Dropbox_ShareFileTable();
            s.ShaId = c.SId;
            s.ShareName = c.SName;
            s.ShareMemory = c.SMemory;
            s.ShareDate = DateTime.Now;
            s.ShareUrl = "http://localhost:27203/SkyDrive/fengxiangwenjian.aspx?id=" + s.ShaId;
            s.ShaUrl = c.SUrl;
            s.ShaName = name;
            System.Random Random = new System.Random();
            int Result = Random.Next(0, 9999);
            s.SharePwd = Result.ToString();
            string aa = s.ShaId + "," + s.SharePwd;
            int a = Sky.Add(s);
            if (a > 0)
            {
                context.Response.Write(aa);

            }
            else
            {
                context.Response.Write("<script>alert('添加失败');</script>");
                return;
            }





        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}